const dayjs = require("dayjs");
dayjs().format();

export const filterTime = (val, comformat = "YYYY-MM-DD") => {
  if (isNull(val)) {
    return "--";
  }
  val = parseInt(val);
  return dayjs(val).format(comformat);
};

export const isNull = (date) => {
  if (!date) return true;
  if (JSON.stringify(date) === "{}") return true;
  if (JSON.stringify(date) === "[]") return true;
  return false;
};

export default (app) => {
  app.config.globalProperties.$filters = {
    filterTime: filterTime,
  };
};
